{include file="public/header"/}
<style>
	.matchCon{width:280px;}
	.tab-item-other {float: left;padding: 5px 15px;line-height: 20px;cursor: pointer;}
  	.tab-item-other a {margin-right: 5px;}
  	.url-box{height: 28px;line-height: 28px;cursor: pointer;}
	.url-box a{margin-right: 5px;}
	.ul-inline li:last-child {float: right;}
</style>

	<div class="bill-ser-top">
		<ul class="ul-inline cf">
			<li>
			<input type="text" id="matchCon" class="ui-input ui-input-ph matchCon" value="" placeholder="输入职员编号/ 职员名称/ 手机号码查询">
			</li>
			<li><a class="ui-btn mrb ui-btn-search" id="search">查询</a></li>
			<!-- <li class="url-box" id="openUrl"><a href="https://club.kingdee.com/club/newclub/school/course?product_id=7&cid=1547#pid=5684" target="_blank" class="video-icon"></a>职员管理</li> -->
			<li class="fr">
				<a href="#" class="ui-btn ui-btn-sp mrb ui-btn-add" onclick="lopen('add.html','新增', '400px', '300px')">新增</a>
				<!--<a class="ui-btn mrb" id="btn-disable">禁用</a>
					<a class="ui-btn mrb" id="btn-enable">启用</a>-->
				<!--<a class="ui-btn mrb" id="btn-print">打印</a>-->
				<!--<a class="ui-btn mrb" id="btn-import">导入</a>-->
				<!--<a class="ui-btn mrb" id="btn-export">导出</a>-->
				<a class="ui-btn" id="btn-refresh" onclick="reload()">刷新</a>
			</li>
		</ul>
	</div>

	<div class="wrapper btc">
		<div class="grid-wrap">
			<table id="grid">
			</table>
			<div id="page"></div>
		</div>
	</div>


<script type="text/javascript">
    
    //$(function(){
	$(document).ready(function () {
    	//alert("1111");
    	$("#grid").jqGrid({
	    	url:'/admin/staff/index.html?ajax=100',
	        datatype: "json",//数据来源，本地数据（local，json,jsonp,xml等）
	        height:'90%',//高度，表格高度。可为数值、百分比或'auto'
	        //width: Public.setGrid().w,
	        //height: Public.setGrid().h,
	        colNames: ["操作", "编号", "名称", "电话", "状态"],
	        colModel:[
	            {name:'id',index:'id', width:70, formatter: cLink}, 
	            {name:'sn', width:150, editable: true},
	            {name:'name',index:'name asc', width:350},
	            {name:'telephone',index:'telephone asc', width:350},
	            {name: 'status', index: 'name asc', width:100, align:"center", formatter: cStatus },
	       	],
	       	// cellsubmit:false,
	        rowNum:10,
	       	rowList:[10,20,30],
	        sortname: 'id',
	     	sortorder: "desc",
	     	pagerpos:"left",//分页位置
	     	
	     	pgbuttons:true,//翻页按钮
	     	pagination:true,
	     	altRows: !0,
	        gridview: !0,
	        shrinkToFit: !1,
	        cellLayout: 8,
	        autowidth: !0,
	        pager: "#page",
	        viewrecords: !0,
	        cmTemplate: {
	            sortable: !1,
	            title: !1
	        },
		    loadError: function(t, e, i) {
			    parent.Public.tips({
			        type: 1,
			        content: "操作失败了哦，请检查您的网络链接！"
			    })
			}
   		});

		function cLink(cellvalue, options, rowObject){
		    return '<div class="operating"><span class="ui-icon ui-icon-pencil" onclick="lopen(\'edit.html?id='+rowObject.id+'\',\'编辑\',\'400px\',\'300px\')">修改</span> <span class="ui-icon ui-icon-trash" onclick="del('+rowObject.id+')">删除</span></div>';
		}

		function cStatus(cellvalue, options, rowObject) {
			console.log(rowObject.status);
			if(rowObject.status == 0){
				return '<span class="set-status open" data-delete="false" onclick="switchs(this,'+rowObject.id+')"><span class="ui-icon-circle"></span></span>';
			}else{
				return '<span class="set-status close" data-delete="false" onclick="switchs(this,'+rowObject.id+')"><span class="ui-icon-circle"></span></span>';
			}
			
		}
	});

	function switchs(obj, id) {
		if($(obj).hasClass("open")){
			$(obj).removeClass("open");
			$(obj).addClass("close");
			status = 1;
		}else{
			$(obj).removeClass("close");
			$(obj).addClass("open");
			status = 0;
		}

		$.ajax({
			type: 'POST',
			url: "save.html",
			data: {id:id,status:status},
			dataType: "json",
			async: false,
			error: function (request) {
				layer.msg("发送请求失败！");
			},
			success: function (data) {
				if (data.status == 1) {
					layer.msg(data.msg);
				} else {
					layer.msg(data.msg);
				}

			}
		});
	}
	$("#search").click(function(){
		var matchCon = $("#matchCon").val();
		$("#grid").jqGrid('setGridParam', {
	        datatype: 'json',
	        postData: { 'ajax' : '100', 'matchCon' : matchCon  }, //发送数据 
	        page: 1
      	}).trigger("reloadGrid"); //重新载入
      	
      	//删除查询缓存
		var postData = $("#grid").jqGrid("getGridParam" , "postData");
　　　　 $.each( postData , function ( k , v ) { 
			delete postData[k];  
　　　　 });
	})
</script>
 

{include file="public/footer"/}
		
